<?php
    $username = $_GET['username'];
    $password = $_GET['password'];
    $usertel = $_GET['usertel'];

    $con = mysqli_connect('localhost','root','123456','user');
    $selectSql = "SELECT * FROM `userlist` WHERE `username`='$username'";

    $selectRes = mysqli_query($con,$selectSql);
    
    $row = mysqli_fetch_assoc($selectRes);

    print_r($row);
    
    if($row){ 
        die('用户名已经存在 请重新输入');
    }

    


    if(!$row){
        $insertSql = "INSERT INTO `userlist` VALUES(null,'$username','$password','$usertel')";
        $insertRes = mysqli_query($con,$insertSql);
        die('注册成功');
    }
    // else{
    //     $arr = array('code'=>$insertRes,'msg'=>'添加成功');
    //     print_r(json_encode($arr,JSON_UNESCAPED_UNICODE));
    // }
    
?>